<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@include file="/static/common/taglib.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <title>日志统计</title>
    <%@include file="../../public/commonCss.jsp" %>
    <%@include file="../../public/commonJs.jsp" %>
</head>
<body ms-controller="main">
<div id="wrapper">
    <div class="boxtoolbar whiteBox actionArea contentbox">
        <div class="layui-inline">
            <div class="layui-input-inline">
                <input type="text" style="width:250px" ms-duplex="searchKey.searchKey"
                       placeholder="搜索、人员姓名、人员编号、物品名称" class="layui-input"/>
            </div>
        </div>
        <div class="layui-inline">
            <div class="layui-input-inline">
                <input type="text" ms-duplex="searchKey.recordDate" class="layui-input Wdate"
                       placeholder="搜索记录日期" onClick="WdatePicker({readOnly:true,maxDate:'%y-%M-%d'})"/>
            </div>
        </div>
        <div class="layui-inline">
            <div class="layui-input-inline">
                <select ms-duplex="searchKey.recordType">
                    <option value="">--请选择记录类型--</option>
                    <option value="1">领取</option>
                    <option value="0">归还</option>
                </select>
            </div>
        </div>
        <div class="layui-inline">
            <div class="layui-input-inline">
                <button class="layui-btn layui-btn-normal layui-btn-small" ms-on-click="searchData()">搜索</button>
            </div>
        </div>
    </div>
    <div class="boxmain whiteBox lrbox" style="margin-top:-90px">
        <div class="lrboxmain borderL" style="margin-left:0%">
            <div class="from-body contentbox" style=" overflow: auto;">
                <table class="layui-table">
                    <thead>
                    <tr align="center">
                        <th>行号</th>
                        <th>人员编号</th>
                        <th>人员姓名</th>
                        <th>物品名称</th>
                        <th>物品分类</th>
                        <th>登录交路</th>
                        <th>登录车组号</th>
                        <th>归还或领取</th>
                        <th>记录时间</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr align="center" ms-repeat="tableDatas">
                        <td>{{(currentPage-1)*pageSize+$index+1}}</td>
                        <td>{{el.userNum}}</td>
                        <td>{{el.userName}}</td>
                        <td>{{el.thingName}}</td>
                        <td>{{el.thingType}}</td>
                        <td>{{el.roadName}}</td>
                        <td>{{el.trainNum}}</td>
                        <td>{{el.recordType=="1"?"领取":"归还"}}</td>
                        <td>{{el.recordTime}}</td>
                    </tr>
                    </tbody>
                </table>
                <!-- 分页 -->
                <div id="demo" class="fenye">
                </div>
            </div>
        </div>
    </div>
    <!-- whitebox -->
</div>
<script type="text/javascript">
    var vm;
    avalon.ready(function () {
        vm = avalon.define({
            $id: "main",
            tableDatas: [],//图片数据
            currentPage: 1,
            pageSize: 15,
            searchKey: {
                searchKey: "",
                recordType: "",//记录类型
                recordDate: ""//记录日期

            }
        })
        avalon.scan();
        loadTableData(1);
    });

    function searchData() {
        loadTableData(1);
    }

    //加载表格数据
    function loadTableData(curr) {
        var dataStr = $.param(vm.$model.searchKey);
        dataStr = dataStr + '&currentPage=' + vm.$model.currentPage;
        $.ajax({
            type: 'post',
            url: '${ctx}/thingUseController/selectOnePage.action',
            data: dataStr,
            dataType: "json",
            timeout: 10000,
            beforeSend: function () {
                top.layer.msg('正在加载...', {time: 0, icon: 16, shade: 0.02});
            },
            success: function (data) {
                top.layer.closeAll();
                vm.tableDatas = data.result;
                layui.laypage({
                    cont: 'demo',
                    pages: data.totalPage,
                    curr: curr || 1, //当前页
                    skip: true,
                    skin: '#1E9FFF',
                    jump: function (obj, first) {
                        if (!first) {
                            vm.currentPage = obj.curr;
                            loadTableData(obj.curr);
                        }
                    }
                });

            }
        });

    }
</script>
</body>
</html>